package com.lanou3g.mynewstest.module.news;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.lanou3g.mynewstest.module.news.comic.ComicFragment;
import com.lanou3g.mynewstest.module.news.headline.HeadlineFragment;
import com.lanou3g.mynewstest.module.news.jokes.JokesFragment;
import com.lanou3g.mynewstest.module.news.pictures.PicturesFragment;

import java.util.ArrayList;

/**
 * Created by dllo on 16/1/8.
 */
public class NewsAdapter extends FragmentPagerAdapter{
    ArrayList<Fragment> data;
    Context context;
    String title1="头条";
    String title2="图片";
    String title3="段子";
    String title4="漫画";
    String titles[]={title1,title2,title3,title4};

    public NewsAdapter(FragmentManager fm,Context  c) {
        super(fm);
        data=new ArrayList<>();
        data.add(new HeadlineFragment());
        data.add(new PicturesFragment());
        data.add(new JokesFragment());
        data.add(new ComicFragment());
        this.context=c;
    }

    @Override
    public Fragment getItem(int position) {
        return data.get(position);
    }

    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return titles[position];
    }


}
